//
//  SYBaseContract.swift
//  Entrance
//
//  Created by chunhuiLai on 2018/1/10.
//  Copyright © 2018年 chunhuiLai. All rights reserved.
//

import UIKit
import YourFilm

protocol SYBaseView: class {
    func showLoading()
    func hideLoading()
    
    func flashMessage(_ message: String?)
    
//    func alert(withTitle title: String, message: String, dismissTitle: String, in view: UIViewController?, withDismissAction dismissAction: (() -> Void)?)
//
//    func alert(title: String, message: String?, dismissTitle: String, confirmtitle: String, inViewController viewController: UIViewController?, confirmAction: (() -> Void)?)
}

extension SYBaseView where Self: UIViewController {
    
    func showLoading() {
      //  YourFilm.showActivityIndicator()
    }
//    func showLoading(style: TDWLoadingStyle) {
//        if let controller = self as? UIViewController {
//            controller.view.tdw_showLoading(style: .gray)
//        }
//        
//    }
//    
    func hideLoading() {
       //YourFilm.curtainCall()
    }

    func flashMessage(_ message: String?) {
        
       // YourFilm.show(HUD(content: HUDContent.label(message)))
    }
}


//MARK: UIView
protocol Shakeable: Equatable { }

extension Shakeable where Self: UIView {
    
    func shake() {
        let shakeAnimation = CAKeyframeAnimation(keyPath: "transform.translation.x")
        shakeAnimation.values = [-5, 0, 5, 5]
        shakeAnimation.repeatCount = 3
        shakeAnimation.duration = 0.1
        layer.add(shakeAnimation, forKey: nil)
    }
}
